<template>
  <div class="hljs">
    <el-form :model="dataFrom"
             size="small"
             ref="dataForm"
             :rules="dataFormRules"
             label-width="120px">
      <div class="system">彩信配置</div>
      <el-form-item label="接口地址" prop="url">
        <el-input v-model="dataFrom.url" placeholder="请输入接口地址"></el-input>
      </el-form-item>
      <el-form-item label="认证账户" prop="userAccount">
        <el-input v-model="dataFrom.userAccount" placeholder="请输入认证账户"></el-input>
      </el-form-item>
      <el-form-item label="认证秘钥" prop="password">
        <el-input v-model="dataFrom.password" placeholder="请输入认证秘钥"></el-input>
      </el-form-item>
      <el-form-item label="ecname" prop="ecname">
        <el-input v-model="dataFrom.ecname" placeholder="请输入ecname"></el-input>
      </el-form-item>
      <el-form-item label="签名" prop="singNo">
        <el-input v-model="dataFrom.singNo" placeholder="请输入签名"></el-input>
      </el-form-item>
    </el-form>
    <div style="text-align: left">
      <el-button
        :loading="dialogLoading"
        @click="submitForm"
        type="primary"
        size="small">
        保存
      </el-button>
    </div>
  </div>
</template>

<script>
  import {queryConfigMms} from '@/api/dailyweekly/workflow'
  export default {
    props: {
      dataFrom: {
        type: Object
      },
    },
    data() {
      return {
        dialogLoading: false,
        // dataFrom: {
        //   url: '',
        //   userAccount: '',
        //   password: '',
        //   ecname: '',
        //   singNo: ''
        // },
        dataFormRules: {
          url: [
            { required: true, message: '请输入接口地址', trigger: 'blur' }
          ],
          userAccount: [
            { required: true, message: '请输入认证账户', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入认证秘钥', trigger: 'blur' }
          ],
          ecname: [
            { required: true, message: '请输入ecname', trigger: 'blur' }
          ],
          singNo: [
            { required: true, message: '请输入签名', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      submitForm () {
        this.$refs['dataForm'].validate(valid => {
          if (valid) {
            this.AddConfigDaily()
          }
        })
      },
      async AddConfigDaily () {
        const data = await queryConfigMms(this.dataFrom, 'post')
        if (data) {
          if (data.code === 200) {
            this.$emit('queryConfigDatily')
          }
        }
      }
    }
  }
</script>
